#ifndef _MY_MAP_TCC_
#define _MY_MAP_TCC_

template<typename Key, typename Value, typename Hash>
my_map<Key, Value, Hash>::my_map(const unsigned int n, Hash h):
buckets(n), hasher(h) {
	for (int i = 0; i < n; i++) {
		buckets[i].reset(new bucket<Key, Value>);
	}
}

template<typename Key, typename Value, typename Hash>
bucket<Key, Value>& my_map<Key, Value, Hash>::getBucket(const Key& key) const {
	const int k = hasher(key) % buckets.size();
	return *buckets[k];
}

template<typename Key, typename Value, typename Hash>
Value my_map<Key, Value, Hash>::value_for(const Key& key, const Value& defaultValue) const {
	return getBucket(key).value_for(key, defaultValue);
}

template<typename Key, typename Value, typename Hash>
void my_map<Key, Value, Hash>::add_or_update_mapping(const Key& key, const Value& value) {
	return getBucket(key).add_or_update_mapping(key, value);
}

template<typename Key, typename Value, typename Hash>
void my_map<Key, Value, Hash>::remove(const Key& key) {
	return getBucket(key).remove(key);
}

template<typename Key, typename Value, typename Hash>
bucket<Key, Value>& my_map<Key, Value, Hash>::getBucketIndex(const int index) const {
	return *buckets[index];
}

#endif
